
#include "include.h"

int sos_page_flush_icache(sos_pcb *pcb, seL4_Word proc_vaddr) {
    int err;
    page_table_entry *pte;

    err = page_walk_nofault(pcb, proc_vaddr, &pte);
    if (err) return err;

    if (pte->attrs.swapped || pte->framenumber == 0) {
        // Precondition not met - page is not mapped
        return SOS_PAGE_TABLE_FAULT;
    }

    err = frame_flush_icache(pte->framenumber);
    return err;
}
